/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author johnny
 */
@Entity
@Table(catalog = "celulares", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Factura.findAll", query = "SELECT f FROM Factura f"),
    @NamedQuery(name = "Factura.findByNumero", query = "SELECT f FROM Factura f WHERE f.numero = :numero"),
    @NamedQuery(name = "Factura.findByDescuento", query = "SELECT f FROM Factura f WHERE f.descuento = :descuento"),
    @NamedQuery(name = "Factura.findByEstado", query = "SELECT f FROM Factura f WHERE f.estado = :estado"),
    @NamedQuery(name = "Factura.findByFechaEmision", query = "SELECT f FROM Factura f WHERE f.fechaEmision = :fechaEmision"),
    @NamedQuery(name = "Factura.findByIva0", query = "SELECT f FROM Factura f WHERE f.iva0 = :iva0"),
    @NamedQuery(name = "Factura.findByIva12", query = "SELECT f FROM Factura f WHERE f.iva12 = :iva12"),
    @NamedQuery(name = "Factura.findBySubtotal", query = "SELECT f FROM Factura f WHERE f.subtotal = :subtotal"),
    @NamedQuery(name = "Factura.findByTotal", query = "SELECT f FROM Factura f WHERE f.total = :total"),
    @NamedQuery(name = "Factura.findByGuiaRemision", query = "SELECT f FROM Factura f WHERE f.guiaRemision = :guiaRemision")})
public class Factura
  implements Serializable
{
  private static final long serialVersionUID = 1L;

  @Id
  @Basic(optional=false)
  @Column(nullable=false)
  private Integer numero;

  @Column(precision=22)
  private Double descuento;

  @Column(length=45)
  private String estado;

  @Column(name="fecha_emision")
  @Temporal(TemporalType.DATE)
  private Date fechaEmision;

  @Column(precision=22)
  private Double iva0;

  @Column(precision=22)
  private Double iva12;

  @Column(precision=22)
  private Double subtotal;

  @Column(precision=22)
  private Double total;

  @Column(name="guia_remision", length=45)
  private String guiaRemision;

  @OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="numero")
  private List<Detallefactura> detallefacturaList;

  @JoinColumn(name="cedula_cliente", referencedColumnName="cedula", nullable=false)
  @ManyToOne(optional=false)
  private Cliente cedulaCliente;

  public Factura()
  {
  }

  public Factura(Integer numero)
  {
    this.numero = numero;
  }

  public Integer getNumero() {
    return this.numero;
  }

  public void setNumero(Integer numero) {
    this.numero = numero;
  }

  public Double getDescuento() {
    return this.descuento;
  }

  public void setDescuento(Double descuento) {
    this.descuento = descuento;
  }

  public String getEstado() {
    return this.estado;
  }

  public void setEstado(String estado) {
    this.estado = estado;
  }

  public Date getFechaEmision() {
    return this.fechaEmision;
  }

  public void setFechaEmision(Date fechaEmision) {
    this.fechaEmision = fechaEmision;
  }

  public Double getIva0() {
    return this.iva0;
  }

  public void setIva0(Double iva0) {
    this.iva0 = iva0;
  }

  public Double getIva12() {
    return this.iva12;
  }

  public void setIva12(Double iva12) {
    this.iva12 = iva12;
  }

  public Double getSubtotal() {
    return this.subtotal;
  }

  public void setSubtotal(Double subtotal) {
    this.subtotal = subtotal;
  }

  public Double getTotal() {
    return this.total;
  }

  public void setTotal(Double total) {
    this.total = total;
  }

  public String getGuiaRemision() {
    return this.guiaRemision;
  }

  public void setGuiaRemision(String guiaRemision) {
    this.guiaRemision = guiaRemision;
  }
  @XmlTransient
  @JsonIgnore
  public List<Detallefactura> getDetallefacturaList() {
    return this.detallefacturaList;
  }

  public void setDetallefacturaList(List<Detallefactura> detallefacturaList) {
    this.detallefacturaList = detallefacturaList;
  }

  public Cliente getCedulaCliente() {
    return this.cedulaCliente;
  }

  public void setCedulaCliente(Cliente cedulaCliente) {
    this.cedulaCliente = cedulaCliente;
  }

  public int hashCode()
  {
    int hash = 0;
    hash += (this.numero != null ? this.numero.hashCode() : 0);
    return hash;
  }

  public boolean equals(Object object)
  {
    if (!(object instanceof Factura)) {
      return false;
    }
    Factura other = (Factura)object;
    if (((this.numero == null) && (other.numero != null)) || ((this.numero != null) && (!this.numero.equals(other.numero)))) {
      return false;
    }
    return true;
  }

  public String toString()
  {
    return "com.mycompany.entidades.Factura[ numero=" + this.numero + " ]";
  }
}